import { ApiPrefixEnum } from '@/enums'
import { get, post, put } from '@/utils/http'

// 获取App列表
export function getAppList(data: any) {
  return get<any>(`${ApiPrefixEnum.CONTRACT}/paas/ops/app/page`, { params: data })
}

// 获取商户列表
export function getTenantList() {
  return get<any>(`${ApiPrefixEnum.CONTRACT}/paas/ops/tenant/options`, { })
}

// 创建应用
export function createApp(data: any) {
  return post<any>(`${ApiPrefixEnum.CONTRACT}/paas/ops/app`, data)
}

// 更新应用
export function updateApp(data: any) {
  return put<any>(`${ApiPrefixEnum.CONTRACT}/paas/ops/app`, data)
}

// 获取应用配置项
export function getAppSettingItems() {
  return get<any>(`${ApiPrefixEnum.CONTRACT}/paas/ops/app/setting/items`, {})
}

// 获取应用配置项表单项
export function getAppSettingFormItems(settingKey: string) {
  return get<any>(`${ApiPrefixEnum.CONTRACT}/paas/ops/app/setting/form/definition`, {
    params: {
      settingKey,
    },
  })
}

// 获取应用配置项表单项
export function getAppSettingFormItemValue(appId: string, settingKey: string) {
  return get<any>(`${ApiPrefixEnum.CONTRACT}/paas/ops/app/setting/value`, {
    params: {
      appId,
      settingKey,
    },
  })
}

// 获取应用配置项表单项
export function saveAppSetting(data: any) {
  return post<any>(`${ApiPrefixEnum.CONTRACT}/paas/ops/app/setting/save`, data)
}
